package com.cf.log.core;


import com.cf.crud.service.AbsBaseService;
import com.cf.id.SnowflakeId;
import com.cf.log.core.dao.LogMapper;
import com.cf.util.ObjectJsonUtil;
import lombok.extern.slf4j.Slf4j;
import com.cf.log.core.domain.Log;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.io.IOException;

/**
 * game-server-LogPersistenceServiceImpl
 *
 * @author <a href="2428922347@qq.com">Zhu mingming</a>
 * @info
 * @since 2018/5/16 下午 02:15
 */
@Slf4j
public class LogPersistenceServiceImpl extends AbsBaseService<Log, LogMapper> implements LogPersistenceService {

    @Autowired
    private SnowflakeId id;

    @Override
    @Transactional(propagation = Propagation.REQUIRES_NEW)
    public void persistenceLog(Log logData) {
        try {
            logData.setId(id.nextId());
            this.mapper.insert(logData);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    public Class getTargetClass() {
        return Log.class;
    }
}
